﻿namespace PowerSong.SongDatabase
    {
    using System;
    using System.IO;

    public class Category : BaseEntity
        {

        public string Name { get; set; }

        public bool IsDefault { get; set; }

        public Category()
            : this(string.Empty)
            {
            }

        public Category(string name, bool isDefault = false)
            : base(FileEntryType.Category, 1)
            {
            this.Name = name;
            this.IsDefault = isDefault;
            }

        internal override bool Deserialise(Database database, BinaryReader reader, int version)
            {

            // Ensure the version is correct
            if (version != 1) return false;

            // Get the details
            this.Name = reader.ReadString();
            this.IsDefault = reader.ReadBoolean();

            // Details read in successfully
            return true;

            }

        internal override void Serialise(BinaryWriter writer)
            {
            writer.Write(Name);
            writer.Write(IsDefault);
            }

        public override string ToString()
            {
            return Name;
            }

        }

    }
